import { Base, Item } from "../base";
const bjesf_url = "https://beijing.anjuke.com/sale/p1/?pi=baidu-cpc-bj-tyong2&kwid=39010834449&utm_term=%E6%88%BF%E5%9C%B0%E4%BA%A7%E4%BF%A1%E6%81%AF%E7%BD%91#filtersort";
class bjesf extends Base {
    form: any;
    firstPage: string;
    houseName: string;
    area: number;
    price: number;
    address: string;
    constructor() {
        super();
        this.name = "北京房地产-北京二手房网";
        this.enabled = true;
        this.encode = "utf-8";
        this.debug = false;
        this.timeout = 1000000;
        this.collection = "bjesf";
        this.keyField = "title";
        this.houseName = "";
    }
    getItems(pageIndex: number): Item[] {
        let urlNums: any[] = [];
        let pageCounts = this.getPageCount();
        let result: Item[] = [];
        let num = pageIndex + 1;
        let url = 'https://beijing.anjuke.com/sale/p' + num + '/?pi=baidu-cpc-bj-tyong2&kwid=39010834449&utm_term=%25E6%2588%25BF%25E5%259C%25B0%25E4%25BA%25A7%25E4%25BF%25A1%25E6%2581%25AF%25E7%25BD%2591#filtersort';
        let content = this.spider.getSync(url);
        let $ = this.cheerio.load(content);
        let that = this;
        $('#houselist-mod-new li').each((index, ele) => {
            let item: Item = that.buildItem();
            (item as any)['title'] = $(ele).find('.house-title a').text();
            (item as any)['类型'] = $(ele).find('.details-item').eq(0).find('span').eq(0).text();
            (item as any)['面积'] = $(ele).find('.details-item').eq(0).find('span').eq(1).text();
            (item as any)['地址'] = $(ele).find('.details-item span').text();
            (item as any)['价格'] = $(ele).find('.pro-price span').eq(0).text();
            result.push(item);
        });
        return result;
    }
    getPageCount(): number {
        return 20;
    }
}
module.exports = new bjesf();